home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doFluidGradients.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.2 KB  |  103 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  20 Feb 2002
  22. //
  23. //  Description:
  24. //      This is a helper script to set fluid gradient types
  25. //        using the corresponding option box values.
  26. //
  27. global proc doFluidGradients( int $version, string $args[] ) 
  28. {
  29.     if(( $version < 1 ) || ( size( $args ) < 8 )) {
  30.         error( "Incorrect version/argument list" );
  31.         return;
  32.     }
  33.  
  34.     if( !`exists getActiveFluidShapes` ) {
  35.         source getFluidShape.mel;
  36.     }
  37.     string $fluids[] = getActiveFluidShapes();
  38.     if( size( $fluids ) == 0 ) {
  39.         error( "No fluid selected" );
  40.         return;
  41.     }
  42.  
  43.     int $doDensity = $args[0];
  44.     int $densityType = $args[1];
  45.  
  46.     int $doVelocity = $args[2];
  47.     int $velocityType = $args[3];
  48.  
  49.     int $doTemperature = $args[4];
  50.     int $temperatureType = $args[5];
  51.  
  52.     int $doFuel = $args[6];
  53.     int $fuelType = $args[7];
  54.     
  55.     if( !( $doFuel || $doTemperature || $doVelocity || $doDensity ) ) {
  56.         error( "Must choose at least one fluid property on which to apply a gradient" );
  57.         return;
  58.     }
  59.  
  60.     string $densityValues, $densityEnables;
  61.     string $velocityValues, $velocityEnables;
  62.     string $temperatureValues, $temperatureEnables;
  63.     string $fuelValues, $fuelEnables;
  64.  
  65.     // Have enough values for the setAttr cmd to work on 
  66.     // all active fluids.
  67.     //
  68.     for( $f in $fluids ) {
  69.         // "3" is the setAttr value for gradient.
  70.         //
  71.         $densityEnables += "3 ";
  72.         $velocityEnables += "3 ";
  73.         $temperatureEnables += "3 ";
  74.         $fuelEnables += "3 ";
  75.  
  76.         // Have to add three since the option box values
  77.         // are 1-based and the first gradient method ATTR
  78.         // value is 4...
  79.         //
  80.         $densityValues += ($densityType + 3) + " ";
  81.         $velocityValues += ($velocityType + 3) + " ";
  82.         $temperatureValues += ($temperatureType + 3) + " ";
  83.         $fuelValues += ($fuelType + 3) + " ";
  84.     }
  85.  
  86.     if( $doDensity ) {
  87.         evalEcho( "setAttr \".densityMethod\" " + $densityEnables );
  88.         evalEcho( "setAttr \".densityGradient\" " + $densityValues );
  89.     }
  90.     if( $doVelocity ) {
  91.         evalEcho( "setAttr \".velocityMethod\" " + $velocityEnables );
  92.         evalEcho( "setAttr \".velocityGradient\" " + $velocityValues );
  93.     }
  94.     if( $doTemperature ) {
  95.         evalEcho( "setAttr \".temperatureMethod\" " + $temperatureEnables );
  96.         evalEcho( "setAttr \".temperatureGradient\" " + $temperatureValues );
  97.     }
  98.     if( $doFuel ) {
  99.         evalEcho( "setAttr \".fuelMethod\" " + $fuelEnables );
  100.         evalEcho( "setAttr \".fuelGradient\" " + $fuelValues );
  101.     }
  102. }
  103.